//
//  NaviDemoVCTwoViewController.m
//  Lesson
//
//  Created by centling on 15/4/16.
//  Copyright (c) 2015年 Seas.CHENG. All rights reserved.
//

#import "NaviDemoVCTwoViewController.h"

@interface NaviDemoVCTwoViewController ()

@end

@implementation NaviDemoVCTwoViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"page2";
    [self.navigationController setNavigationBarHidden:NO animated:NO];
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithTitle:@"返回" style:UIBarButtonItemStyleBordered target:nil action:nil];
    
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithTitle:@"点击" style:UIBarButtonItemStyleBordered target:self action:@selector(rightItemClick)];


    /*
     一个UINavigationController控制着若干个UIViewController
     一个UINavigationController包含一个UINavigationBar
     UINavigationBar里的“按钮”是UINavigationItem
     通过设置UINavigationItem的属性，现实item
     但UINavigationItem不是由UINavigationBar来控制的，更不是由UINavigationController来控制
     而是有当前的UIViewController来控制
     */
    
    [self.navigationItem setBackBarButtonItem:backItem];
    [self.navigationItem setRightBarButtonItem:rightItem];
    // Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

-(void)rightItemClick{
    UIAlertView *alert=[[UIAlertView alloc] initWithTitle:@"提示" message:@"您点击了返回键" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
    [alert show];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

- (IBAction)back:(id)sender {
    [self.navigationController popViewControllerAnimated:YES];
}

- (IBAction)next:(id)sender {
    UIViewController *threeVC=[self.storyboard instantiateViewControllerWithIdentifier:@"threeVC"];
    [self.navigationController pushViewController:threeVC animated:YES];
}

- (IBAction)codeButtonClick:(id)sender {
    
    
    UIViewController *threeVC=[self.storyboard instantiateViewControllerWithIdentifier:@"threeVC"];
    [self.navigationController pushViewController:threeVC animated:YES];
}
@end
